﻿@model AnnounceInfo
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>通知编辑</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @CourseInfoManage.Instance.GetCourseNameById(Model.CourseId)<br>
            <small>广州中医药大学康复治疗微课程网络学习平台</small>
        </h1>
    </div>
</div>
@*导航菜单*@
@Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 5)
<div class="container mainwrap">
    <div class="row">
        <div class="col-xs-2">
            <div class="dropdown theme-dropdown clearfix">
                <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                    <li class="active" role="presentation">
                        <a role="menuitem" tabindex="-1" href="@Url.Action("AnnounceInfoList", "Announce")?CourseId=@Model.CourseId">
                            <span class="glyphicon glyphicon-cog"></span>通知列表
                        </a>
                    </li>
                    <li role="presentation" class="divider"></li>
                    <li role="presentation">
                        <a role="menuitem" tabindex="-1" href="@Url.Action("AnnounceInfoAdd", "Announce")?CourseId=@Model.CourseId">
                            <span class="glyphicon glyphicon-plus"></span>通知新增
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-xs-10">
            <div class="panel panel-default mainwrap-part">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <ol class="breadcrumb">
                            <li>通知管理</li>
                            <li class="active">通知编辑</li>
                        </ol>
                    </h3>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <form id="frm" role="form" class="form-horizontal">
                            @Html.Hidden("Id")
                            <div class="form-group clearfix">
                                <label for="firstname" class="col-xs-2 control-label">通知标题：</label>
                                <div class="col-xs-4">
                                    <input type="text" class="form-control input-md" name="Title" value="@Model.Title" placeholder="请输入通知标题">
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <label for="firstname" class="col-xs-2 control-label">通知内容：</label>
                                <div class="col-xs-10">
                                    <textarea id="AnnounceContent" name="AnnounceContent" class="form-control" style="width: 100%; height: 300px;">@Model.AnnounceContent</textarea>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <label for="firstname" class="col-xs-2 control-label">是否停用：</label>
                                <div class="col-xs-2">
                                    <select class="form-control" name="IsStop">
                                        <option value=true @(Model.IsStop.Value ? "selected" : "")>是</option>
                                        <option value=false @(Model.IsStop.Value ? "" : "selected")>否</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <div class="col-xs-offset-2 col-xs-10">
                                    <button type="button" onclick="autoSubmit('frm');" class="btn btn-success">保存</button>
                                    <button type="button" onclick="history.go(-1)" class="btn btn-success btn-md"><span class="glyphicon glyphicon-arrow-left"></span>返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@Html.Partial("~/Views/Share/PublicFooter.cshtml")
@Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
<script src="~/Content/jquery.form.js"></script>
<script src="../Content/kindeditor/kindeditor-min.js"></script>
<script src="../Content/kindeditor/lang/zh_CN.js"></script>
<script>


    KindEditor.ready(function (K) {
        window.editor = K.create('#AnnounceContent', {
            uploadJson: '@Url.Content("~/upload_json.ashx")',
            fileManagerJson: '@Url.Content("~/file_manager_json.ashx")',
            allowFileManager: true
        });
    });



    var t = true;
    function autoSubmit(frmId) {

        $("#AnnounceContent").val("");

        var frm2 = $("#" + frmId);
        var Id = frm2.find("#Id").val();
        var Title = frm2.find("input[name='Title']").val();
        var AnnounceContent = editor.html();
        var IsStop = frm2.find("select[name='IsStop'] option:selected").val();
        var jsonData = {
            "Id": Id,
            "Title": Title,
            "IsStop": IsStop,
            "AnnounceContent": AnnounceContent
        };

        var url = "@Url.Action("AnnounceInfoEdit", "Announce")";
        var options = {
            type: 'POST',
            data: jsonData,
            url: url,
            async: false,
            cache: false,
            success: function (data) {
                if (data.result) {
                    showTips.open("编辑成功");
                }
                else {
                    showTips.open(data.message);
                }
            }
        }
        if (t) {
            t = false;
            $.ajax(options);
            t = true;
        }
    };
</script>
</body>
</html>

